import request from "../utils/request";
export const login = (data) => {
  return request({
    method: "post",
    url: "login",
    data,
  });
};
//获取左侧用户列表数据
export const getmenus = (data) => {
  return request({
    method: "get",
    url: "menus",
    
  });
};
//获取用户列表数据
export const getUserList = (params) => {
  return request({
    url: "users",
    params
    
  });
};
//更新用户状态
export const updateUser = (data) => {
  return request({
    url: `users/${data.id}/state/${data.mg_state}`,
    method:'put'
     
  });
};


//添加用户列表数据
export const addUser = (data) => {
  return request({
    url: "users",
    method:'post',
    data
    
  });
};
//删除用户列表数据
export const delUser = (id) => {
  return request({
    url: `users/${id}`,
    method:'delete',
 
    
  });
};

//修改用户渲染
export const editUser = (id) => {
  return request({
    url: `users/${id}`,  
  });
};
export const editUserList = (id,data) => {
  return request({
    url: `users/${id}`,  
    method: 'put',
    data
  });
};
//获取角色列表
export const getJJ = () => {
  return request({
    url: `roles`,  
  });
};

//更新用户角色
export const upjj = (id,data) => {
  return request({
    url: `users/${id}/role`,  
    method: 'put',
    data
  });
};
export const deljj = (id,itemid) => {
  return request({
    url: `roles/${id}/rights/${itemid}`,  
    method: 'delete',
   
  });
};
//角色列表添加角色
export const addJJ = (data) => {
  return request({
    url: `roles`,  
    method: 'post',
    data
  });
};
//编辑角色列表
export const eddJJ = (id) => {
  return request({
    url: `roles/${id}`,  
  });
};
// 编辑角色列表
export const addupjj = (id,data) => {
  return request({
    url: `roles/${id}`,  
    method: 'put',
    data
  });
};
//删除角色列表
export const deletejj = (id) => {
  return request({
    url: `roles/${id}`,
    method: 'delete',
   
  })
}
export const fqq = () => {
  return request({
    url: `rights/tree`,
    
   
  })
}
//分配权限
export const fpqx = (id,data) => {
  return request({
    url: `roles/${id}/rights`,
    method: 'post',
    data
   
  })
}
//获取权限列表
export const getqxlist = () => {
  return request({
    url: `rights/list`,
   
  
   
  })
}

//获取商品列表数据
export const getGoodsList = (params) => {
  return request({
    url: "goods",
    params
    
  });
};
//编辑商品列表
export const editGoodsList = (id) => {
  return request({
    url: `goods/${id}`
     
  });
};
//编辑商品信息
export const editgoods = (id,data,itemid) => {
  return request({
    url: `users/${id}/role/${itemid}`,  
    method: 'put',
    data
  });
};

//删除商品列表
export const delGoodsList = (id) => {
  return request({
    url: `goods/${id}`,
     method:'delete'
  });
};

//获取商品分类
export const getcart = () => {
  return request({
    url: `categories`,
    
  });
};
export const getattributes= (params) => {
  return request({
    url: `categories/${this.cateId}/attributes`,
    params
    
  });
};

//获取订单列表
export const getorder = (params) => {
  return request({
    url: `orders`,
    params
    
  });
}

//修改订单列表
export const editorders = (id) => {
  return request({
    url: `orders/${id}`,
    
    
  });
}
export const uporders = (id,data) => {
  return request({
    url: `orders/${id}`,
    method: 'put',
    data
    
    
  });
}
//获取商品分类
export const getcartlist = (params) => {
  return request({
    url: `categories`,
    params
    
  });
};

// 获取商品分类数据
export const getsp = (params) => {
  return request({
    url: `categories`,
    params
    
  });
};
export const addsp = (data) => {
  return request({
    url: `categories`,
    data,
    method:'post'
    
  });
};
// 获取商品分类数据
export const getspp = (id) => {
  return request({
    url: `categories/${id}`,
  
    
  });
}
export const putspp = (data,id) => {
  return request({
    url: `categories/${id}`,
    method: 'put',
     data
    
  });
}
export const delspp = (id) => {
  return request({
    url: `categories/${id}`,
    method: 'delete',
     
    
  });
}
export const getcate = (id,params) => {
  return request({
    url: `categories/${id}/attributes`,
    params
     
    
  });
}
export const getonlycate = (id,params) => {
  return request({
    url: `categories/${id}/attributes`,
    params
     
    
  });
}
export const addform = (data) => {
  return request({
    url: `goods`,
    method:'post',
    data
     
    
  });
}
export const getparams= () => {
  return request({
    url: `categories`,
   
    
     
    
  });
}
export const getii= (id,params) => {
  return request({
    url: `categories/${id}/attributes`,
    params
    });
}
export const addp = (id,data) => {
  return request({
    url: `categories/${id}/attributes`,
    data,
    method:'post'
    });
}
export const editp = (id1,id2,params) => {
  return request({
    url:  `categories/${id1}/attributes/${id2}`,
    params,
    
    });
}
export const putp = (id1,id2,data) => {
  return request({
    url:  `categories/${id1}/attributes/${id2}`,
    data,
    method:'put'
    
    });
}
export const delp = (id1,id2) => {
  return request({
    url:  `categories/${id1}/attributes/${id2}`,
    
    method:'delete'
    
    });
}